package com.touchealth.test.collection;

import com.touchealth.test.bean.Book;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhangyanqiang
 * @date 2020/3/11
 **/
public class DuplicateKey {


    public static void main(String[] args) {

        Book book1 = new Book();
        book1.setName("zhang");
        book1.setHeight(12);
        Book book2 = new Book();
        book2.setName("zhang");
        book2.setHeight(13);
        Book book3 = new Book();
        book3.setName("zhang");
        book3.setHeight(14);
        List<Book> list = new ArrayList<>();
        list.add(book1);
        list.add(book2);
        list.add(book3);

        Map<String, List<Book>> orderEvalMap = new HashMap<>(3);
        list.stream().forEach(book -> {
            if (orderEvalMap.get(book.getName()) == null) {
                orderEvalMap.put(book.getName(), new ArrayList<>());
            }
            orderEvalMap.get(book.getName()).add(book);
        });



    }
}
